/***********************************************************************/
/*                                                                     */
/*  FILE        :resetprg.c                                            */
/*  DATE        :Thu, Dec 07, 2006                                     */
/*  DESCRIPTION :initialize for C language.                            */
/*  CPU GROUP   :62P(ROM384K)                                          */
/*                                                                     */
/*  This file is generated by Renesas Project Generator (Ver.4.5).     */
/*                                                                     */
/***********************************************************************/

/*********************************************************************
 *  STARTUP for M16C/60,30,20,10                                      
 *  Copyright(c) 2004 Renesas Technology Corp.
 *  And Renesas Solutions Corp.,All Rights Reserved.
 *  resetprg.c : startup file 
 *
 *  Function:initialize each function
 *
 *
 * $Date: 2005/11/17 06:18:37 $
 * $Revision: 1.16 $
 *********************************************************************/
#include "resetprg.h"
////////////////////////////////////////////
// declare sfr register 
#pragma ADDRESS	protect	0AH
#pragma ADDRESS	pmode0	04H
_UBYTE protect,pmode0;
//DEF_BANKSELECT;
DEF_SBREGISTER;

#pragma entry start
void start(void);
extern void initsct(void);
extern void _init(void);
void exit(int);
void main(void);

#pragma section program interrupt 
#pragma inline set_cpu()
void set_cpu(void)
{
	_isp_	= &_istack_top; 	// set interrupt stack pointer
	protect = 0x02;		// change protect mode register
	pmode0	= 0x00;		// set processor mode register
	protect = 0x00;		// change protect mode register
	_flg_	= 0x0080;	// set flag register
	_sp_	= &_stack_top; 	// set user stack pointer
	_sb_	= (_UINT *)0x400;	// 400H fixation (Do not change)

	// set variable vector's address
	_intbh_ = (_UINT *)((VECTOR_ADR>>16)&0xffff);
	_intbl_ = (_UINT *)(VECTOR_ADR&0xffff);

}

void start(void)
{
	set_cpu();		// initialize mcu
	initsct();		// initlalize each sections
#ifdef __HEAP__
	heap_init();		// initialize heap 
#endif
#ifdef __STANDARD_IO__
	_init();			// initialize standard I/O
#endif
	_fb_ = (_UINT *)0;	// initialize FB registe for debugger
	main();			// call main routine

	exit(0);		// call exit
}

void exit(int rc)
{
	while(1);		// infinite loop
}



